package com.test;
/*
//instanceof 关键字 判断一个对象是否是某个类(或接口)的实例
// 定义Animal类
class Animal {
    public void shout() {
        System.out.println("动物叫……");
    }
}

// 定义Dog类
class Dog extends Animal {
    // 重写shout()方法
    public void shout() {
        System.out.println("汪汪……");
    }

    public void eat() {
        System.out.println("吃骨头……");
    }
}

public class Example09 {
    public static void main(String[] args) {
        Animal animal1 = new Dog();   //子类->父类
        System.out.println("Animal animal1=new Dog()" + (animal1 instanceof Animal));   //Condition 'animal1 instanceof Animal' is always 'true' when reached
        System.out.println("Animal animal1=new Dog()" + (animal1 instanceof Dog));      //Condition 'animal1 instanceof Dog' is always 'true' when reached
        Animal animal2 = new Animal();
        System.out.println("Animal animal2=new Animal()" + (animal1 instanceof Animal));       //Condition 'animal1 instanceof Animal' is always 'true' when reached
        System.out.println("Animal animal2=new Animal()" + (animal1 instanceof Dog));
    }
}

 */
